package com.library.popup;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.validation.BindException;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractFormController;

import com.library.model.service.LoginService;

public class IdCheck extends AbstractFormController {

	private LoginService loginservice;
	
	public void setLoginservice(LoginService loginservice) {
		this.loginservice = loginservice;
	}
	
	@Override
	protected Object formBackingObject(HttpServletRequest request)
			throws Exception {
		return request.getParameter("member_id");
	}

	@Override
	protected ModelAndView processFormSubmission(HttpServletRequest request,
			HttpServletResponse response, Object arg2, BindException arg3)
			throws Exception {
		ModelAndView mav=new ModelAndView();
		int isC=0;
		isC=loginservice.getId((String)arg2);
		request.setAttribute("count", isC);
		request.setAttribute("id",(String)arg2);
		mav.setViewName("idcheckform");
		return mav;
	}

	@Override
	protected ModelAndView showForm(HttpServletRequest arg0,
			HttpServletResponse arg1, BindException arg2) throws Exception {
		return new ModelAndView("idcheckform");
	}

}
